package com.cc.main.problems;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.cc.main.ICommonCmd;
import com.cc.main.problems.bean.KeyWordItem;
import com.cc.main.problems.bean.ProblemBean;
import com.cc.main.util.CcExceeption;
import com.cc.main.util.MyUtils;

public class BaseFilter implements ICommonCmd{
	
	private static BaseFilter bFilter = new BaseFilter();
	public static BaseFilter getInstance() {
		return bFilter;
	}

	@Override
	public void execute(Object action) throws CcExceeption {
		// TODO Auto-generated method stub
		ProblemBean bean = (ProblemBean) action;
		if(bean.dftkeyList.size() == 0 && bean.addkeyList.size() == 0) {
			throw new CcExceeption("关键字为空，无法检索!");
		}
		try {
			List<String> result = MyUtils.filterMsg(bean.dftkeyList,bean.logFileList,bean.addkeyList,bean.timeList);
			bean.result.addAll(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
